import json

from volcengine.ApiInfo import ApiInfo
from volcengine.Credentials import Credentials
from volcengine.ServiceInfo import ServiceInfo
from volcengine.base.Service import Service

k_access_key = 'AKLTMDEwMjNkN2M3MWI1NGNjZWI1NjUyY2YxYTNlZmE5MDg' # https://console.volcengine.com/iam/keymanage/
k_secret_key = 'TXprME1HUTNObU0xTURrMU5EUmpOR0l4T0RSaVlXSTJPRFl3TTJJeE9EZw=='
k_service_info = \
    ServiceInfo('translate.volcengineapi.com',
                {'Content-Type': 'application/json'},
                Credentials(k_access_key, k_secret_key, 'translate', 'cn-north-1'),
                5,
                5)
k_query = {
    'Action': 'TranslateText',
    'Version': '2020-06-01'
}
k_api_info = {
    'translate': ApiInfo('POST', '/', k_query, {}, {})
}
service = Service(k_service_info, k_api_info)
body = {
    'TargetLanguage': 'zh',
    'TextList': ['ResponseMetadata', '世界'],
}
res = service.json('translate', {}, json.dumps(body))
print(json.loads(res))